home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 45 / CD-ROM 45 / CD-ROM 45.iso / aplicat / dominio / Habilite / Disk1 / Habilite.mst < prev    next >
Encoding:
Text File  |  1998-07-08  |  13.0 KB  |  476 lines

  1. '**************************************************************************
  2. '*                       Instalador do Habilite-se!
  3. '**************************************************************************
  4.  
  5. '$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST ASKQUIT      = 200
  12. CONST DESTPATH     = 300
  13. CONST EXITFAILURE  = 400
  14. CONST EXITQUIT     = 600
  15. CONST EXITSUCCESS  = 700
  16. 'CONST OPTIONS      = 800
  17. CONST APPHELP      = 900
  18. CONST CUSTINST     = 6200
  19. CONST TOOBIG       = 6300
  20. CONST BADPATH      = 6400
  21.  
  22. ''Bitmap ID
  23. CONST LOGO         = 1
  24.  
  25. ''File Types
  26. CONST FILES     = 1
  27. '*CONST OPTFILES1    = 2
  28. '*CONST OPTFILES2    = 3
  29.  
  30.  
  31. GLOBAL DEST$        ''Default destination directory.
  32. GLOBAL WINDRIVE$    ''Windows drive letter.
  33. ''GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  34. ''GLOBAL OPT2OPT$     ''Option selection from OptFiles2 option dialog.
  35.  
  36. ''CustInst list symbol names
  37. GLOBAL APPNEEDS$    ''Option list costs per drive
  38. 'GLOBAL OPT1NEEDS$
  39. 'GLOBAL OPT2NEEDS$
  40. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  41. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  42.  
  43. ''Dialog list symbol names
  44. GLOBAL CHECKSTATES$
  45. GLOBAL STATUSTEXT$
  46. GLOBAL DRIVETEXT$
  47.  
  48.  
  49. DECLARE SUB AddOptFilesToCopyList (ftype%)
  50. DECLARE SUB RecalcOptFiles (ftype%)
  51. DECLARE SUB RecalcPath
  52. DECLARE SUB SetDriveStatus
  53. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  54.  
  55.  
  56. ' maximizando a janela
  57. ''following were taken from windows.h. &H means they're hex
  58. CONST WS_VISIBLE=&H10000000
  59. CONST WS_BORDER =&H00800000
  60. CONST WS_CLIPCHILDREN =&H02000000
  61. CONST GWL_STYLE =-16
  62. CONST SW_SHOWMAXIMIZED=3
  63.  
  64. DECLARE FUNCTION ShowWindow  LIB "user.exe" (hWnd%,iShow%) AS INTEGER
  65. DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG     ''this declaration must all be on one line
  66.  
  67. hWnd%=HwndFrame()
  68. i1&=SetWindowLong(hWnd%,GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
  69. j1%=ShowWindow(hWnd%,SW_SHOWMAXIMIZED)
  70. 'fim
  71.  
  72.  
  73.  
  74. INIT:
  75.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  76.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  77.  
  78.     SetBitmap CUIDLL$, LOGO
  79.     SetTitle "Instalaτπo do Software Habilite-se!"
  80.  
  81.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  82.     IF szInf$ = "" THEN
  83.     szInf$ = GetSymbolValue("STF_CWDDIR") + "Habilite.INF"
  84.     END IF
  85.     ReadInfFile szInf$
  86.  
  87.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  88.     DEST$ = WINDRIVE$ + ":\Habilite"
  89.  
  90.     ''CustInst list symbols
  91.     CHECKSTATES$ = "CheckItemsState"
  92.     STATUSTEXT$  = "StatusItemsText"
  93.     DRIVETEXT$   = "DriveStatusText"
  94.     FOR i% = 1 TO 3 STEP 1
  95.         AddListItem CHECKSTATES$, "ON"
  96.     NEXT i%
  97.  
  98.     FOR i% = 2 TO 3 STEP 1
  99.         AddListItem CHECKSTATES$, "OFF"
  100.     NEXT i%
  101.  
  102.     FOR i% = 1 TO 3 STEP 1
  103.         AddListItem STATUSTEXT$, ""
  104.     NEXT i%
  105.     FOR i% = 1 TO 7 STEP 1
  106.         AddListItem DRIVETEXT$, ""
  107.     NEXT i%
  108.     ReplaceListItem DRIVETEXT$, 7, DEST$
  109.  
  110.     ''Disk cost list symbols
  111.     APPNEEDS$   = "AppNeeds"
  112. '    OPT1NEEDS$  = "Opt1Needs"
  113. '    OPT2NEEDS$  = "Opt2Needs"
  114.     EXTRACOSTS$ = "ExtraCosts"
  115.     BIGLIST$    = "BigList"
  116.     FOR i% = 1 TO 3 STEP 1
  117.         AddListItem BIGLIST$, ""
  118.     NEXT i%
  119.     FOR i% = 1 TO 26 STEP 1
  120.         AddListItem EXTRACOSTS$, "0"
  121.     NEXT i%
  122.  
  123.     ''File Option Variables
  124. '    OPT1OPT$ = "1"
  125. '    OPT2OPT$ = "1"
  126.  
  127.     RecalcPath
  128.     SetDriveStatus
  129.  
  130. '$IFDEF DEBUG
  131.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  132. '$ENDIF ''DEBUG
  133.  
  134.  
  135.  
  136. CUSTINST:
  137.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  138.  
  139.     IF sz$ = "CONTINUE" THEN
  140.         ''Install only if it will fit.
  141.         FOR i% = 1 TO 3 STEP 1
  142.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  143.                 GOSUB TOOBIG
  144.                 GOTO CUSTINST
  145.             END IF
  146.         NEXT i%
  147.         UIPop 1
  148.         GOTO INSTALL
  149.     ELSEIF sz$ = "PATH" THEN
  150.         GOTO GETPATH
  151.     ELSEIF sz$ = "CHK1" THEN
  152. '        RecalcOptFiles FILES
  153.         SetDriveStatus
  154.         GOTO CUSTINST
  155.     ELSEIF sz$ = "CHK2" THEN
  156. '        RecalcOptFiles OPTFILES1
  157.         SetDriveStatus
  158.         GOTO CUSTINST
  159.     ELSEIF sz$ = "CHK3" THEN
  160. '        RecalcOptFiles OPTFILES2
  161.         SetDriveStatus
  162.         GOTO CUSTINST
  163. '    ELSEIF sz$ = "BTN2" THEN
  164. '        GOTO OPTFILES1
  165. '    ELSEIF sz$ = "BTN3" THEN
  166. '        GOTO OPTFILES2
  167.     ELSEIF sz$ = "REACTIVATE" THEN
  168.         RecalcPath
  169.         SetDriveStatus
  170.         GOTO CUSTINST
  171.     ELSE
  172.         GOSUB ASKQUIT
  173.         GOTO CUSTINST
  174.     END IF
  175.  
  176.  
  177.  
  178. INSTALL:
  179.     ClearCopyList
  180.     AddOptFilesToCopyList FILES
  181. ''    AddOptFilesToCopyList OPTFILES1
  182. ''    AddOptFilesToCopyList OPTFILES2
  183.     CreateDir DEST$, cmoNone
  184.     CopyFilesInCopyList
  185.  
  186. '    IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
  187. '    ini$ = MakePath(DEST$, "DEMO.INI")
  188. '    CreateIniKeyValue "WIN.INI", "Habilite-se!", "Option1", OPT1OPT$, cmoNone
  189. '    CreateIniKeyValue ini$, "Section 1", "Key 1", "Value 1" , cmoNone
  190. '    CreateIniKeyValue ini$, "Section 2", "Key 2", "Value 2" , cmoNone
  191. '    CreateIniKeyValue ini$, "Section 3", "Key 3", "Value 3" , cmoNone
  192. '    ini$ = ""
  193. '    END IF
  194.  
  195.     IF GetListItem(CHECKSTATES$, FILES) = "ON" THEN
  196.     CreateProgmanGroup "Habilite-se!", "Habilite.grp", cmoNone
  197.     ShowProgmanGroup  "Habilite-se!", 1, cmoNone
  198.     CreateProgmanItem "Habilite-se!", "Habilite-se!", MakePath(DEST$,"Habilite.exe"), "", cmoOverwrite
  199.     CreateProgmanItem "Habilite-se!", "Botπo Habilite-se!", MakePath(DEST$,"botaohab.exe"), "", cmoOverwrite
  200.         'CreateProgmanItem "MSSetup Sample 2", "dlgprocs.c", "notepad.exe "+MakePath(DEST$,"dlgprocs.c"), "", cmoOverwrite
  201.     END IF
  202.  
  203.  
  204. QUIT:
  205.     ON ERROR GOTO ERRQUIT
  206.  
  207.     IF ERR = 0 THEN
  208.     dlg% = EXITSUCCESS
  209.     ELSEIF ERR = STFQUIT THEN
  210.         dlg% = EXITQUIT
  211.     ELSE
  212.         dlg% = EXITFAILURE
  213.     END IF
  214. QUITL1:
  215.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  216.     IF sz$ = "REACTIVATE" THEN
  217.     GOTO QUITL1
  218.     END IF
  219.     prgmdpath$ = MakePath(DEST$,"")
  220.     dirinst$ = CURDIR$("")
  221.     prgmd$ = MakePath(DEST$,"Habilite.exe ") + "$cabaτo$"
  222.     ' + prgmdpath$
  223. ' Ap≤s saφda OK, executa o Habilite-se! para habilitar a instalaτπo
  224.     IF dlg% = EXITSUCCESS THEN
  225.        RUN prgmd$, NOWAIT
  226. '    RUN MakePath(DEST$,"Habilite.exe"), NOWAIT
  227.     END IF
  228. 'DoMsgBox(dirinst$, "Habilite-se! - Mensagem", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  229.     UIPop 1
  230.     END
  231.  
  232. ERRQUIT:
  233.     i% = DoMsgBox("Arquivos adulterados. Chame (051) 2285468!", "Habilite-se! - Mensagem", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  234.     END
  235.  
  236.  
  237.  
  238. GETPATH:
  239.     SetSymbolValue "EditTextIn", DEST$
  240.     SetSymbolValue "EditFocus", "END"
  241. GETPATHL1:
  242.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  243.  
  244.     IF sz$ = "CONTINUE" THEN
  245.         olddest$ = DEST$
  246.         DEST$ = GetSymbolValue("EditTextOut")
  247.  
  248.         ''Validate new path.
  249.         IF IsDirWritable(DEST$) = 0 THEN
  250.             GOSUB BADPATH
  251.             GOTO GETPATHL1
  252.         END IF
  253.         UIPop 1
  254.  
  255.         ''Truncate display if too long.
  256.         IF LEN(DEST$) > 23 THEN
  257.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  258.         ELSE
  259.             ReplaceListItem DRIVETEXT$, 7, DEST$
  260.         END IF
  261.  
  262.         ''Recalc if path changed.
  263.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  264.             RecalcPath
  265.             SetDriveStatus
  266.         END IF
  267.  
  268.         olddest$ = ""
  269.         GOTO CUSTINST
  270.     ELSEIF sz$ = "REACTIVATE" THEN
  271.         RecalcPath
  272.         SetDriveStatus
  273.         GOTO GETPATHL1
  274.     ELSEIF sz$ = "EXIT" THEN
  275.         GOSUB ASKQUIT
  276.         GOTO GETPATHL1
  277.     ELSE
  278.         UIPop 1
  279.         GOTO CUSTINST
  280.     END IF
  281.  
  282.  
  283.  
  284. TOOBIG:
  285.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  286.     IF sz$ = "REACTIVATE" THEN
  287.         RecalcPath
  288.         SetDriveStatus
  289.         GOTO TOOBIG
  290.     END IF
  291.     UIPop 1
  292.     RETURN
  293.  
  294.  
  295.  
  296. BADPATH:
  297.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  298.     IF sz$ = "REACTIVATE" THEN
  299.         RecalcPath
  300.         SetDriveStatus
  301.         GOTO BADPATH
  302.     END IF
  303.     UIPop 1
  304.     RETURN
  305.  
  306.  
  307.  
  308. ASKQUIT:
  309.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  310.  
  311.     IF sz$ = "EXIT" THEN
  312.         UIPopAll
  313.         ERROR STFQUIT
  314.     ELSEIF sz$ = "REACTIVATE" THEN
  315.         GOTO ASKQUIT
  316.     ELSE
  317.         UIPop 1
  318.     END IF
  319.     RETURN
  320.  
  321.  
  322.  
  323. '**
  324. '** Purpose:
  325. '**     Adds the specified option files to the copy list.
  326. '** Arguments:
  327. '**     ftype%  - type of files to add, one of the following:
  328. '**             FILES, OPTFILES1, OPTFILES2
  329. '** Returns:
  330. '**     none.
  331. '*************************************************************************
  332. SUB AddOptFilesToCopyList (ftype%) STATIC
  333.  
  334.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  335.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  336.         IF ftype% = FILES THEN
  337.             AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  338. '        ELSEIF ftype% = OPTFILES1 THEN
  339. '            AddSectionKeyFileToCopyList "OptFiles1", OPT1OPT$, SrcDir$, DEST$
  340. '        ELSEIF ftype% = OPTFILES2 THEN
  341. '            AddSectionKeyFileToCopyList "OptFiles2", OPT2OPT$, SrcDir$, DEST$
  342.         END IF
  343.         SrcDir$ = ""
  344.     END IF
  345. END SUB
  346.  
  347.  
  348. '**
  349. '** Purpose:
  350. '**     Recalculates disk space for the given option files and sets
  351. '**     the status info symbol "StatusItemsText".
  352. '** Arguments:
  353. '**     ftype% - type of files to add, one of the following:
  354. '**             FILES, OPTFILES1, OPTFILES2
  355. '** Returns:
  356. '**     none.
  357. '*************************************************************************
  358. SUB RecalcOptFiles (ftype%) STATIC
  359.     CursorSave% = ShowWaitCursor()
  360.     ClearCopyList
  361.     AddOptFilesToCopyList ftype%
  362.  
  363.     fExtra% = 0
  364.     IF ftype% = FILES THEN
  365.         ListSym$ = APPNEEDS$
  366.         IF GetListItem(CHECKSTATES$, FILES) = "ON" THEN
  367.             ''Add extra cost to Windows drive for ini/progman, etc.
  368.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  369.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  370.             fExtra% = 1
  371.         END IF
  372.     END IF
  373.  
  374.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  375.  
  376.     cost& = 0
  377.     FOR i% = 1 TO 26 STEP 1
  378.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  379.     NEXT i%
  380.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  381.  
  382.     IF StillNeed& > 0 THEN
  383.         ReplaceListItem BIGLIST$, ftype%, "YES"
  384.     ELSE
  385.     ReplaceListItem BIGLIST$, ftype%, ""
  386.     END IF
  387.  
  388.     IF fExtra% THEN
  389.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  390.     END IF
  391.     RestoreCursor CursorSave%
  392.     ListSym$ = ""
  393. END SUB
  394.  
  395.  
  396. '**
  397. '** Purpose:
  398. '**     Recalculates disk space and sets option status info according
  399. '**     to the current destination path.
  400. '** Arguments:
  401. '**     none.
  402. '** Returns:
  403. '**     none.
  404. '*************************************************************************
  405. SUB RecalcPath STATIC
  406.  
  407.     CursorSave% = ShowWaitCursor()
  408.  
  409.     RecalcOptFiles FILES
  410.  
  411.     RestoreCursor CursorSave%
  412. END SUB
  413.  
  414.  
  415. '**
  416. '** Purpose:
  417. '**     Sets drive status info according to latest disk space calcs.
  418. '** Arguments:
  419. '**     none.
  420. '** Returns:
  421. '**     none.
  422. '*************************************************************************
  423. SUB SetDriveStatus STATIC
  424.  
  425.     drive$ = MID$(DEST$, 1, 1)
  426.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  427.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%))
  428.     free& = GetFreeSpaceForDrive(drive$)
  429.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  430.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  431.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  432.  
  433.     IF drive$ = WINDRIVE$ THEN
  434.         ReplaceListItem DRIVETEXT$, 4, ""
  435.         ReplaceListItem DRIVETEXT$, 5, ""
  436.         ReplaceListItem DRIVETEXT$, 6, ""
  437.     ELSE
  438.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  439.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%))
  440.         IF cost& = 0 THEN
  441.             ReplaceListItem DRIVETEXT$, 4, ""
  442.             ReplaceListItem DRIVETEXT$, 5, ""
  443.             ReplaceListItem DRIVETEXT$, 6, ""
  444.         ELSE
  445.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  446.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  447.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  448.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  449.         END IF
  450.     END IF
  451. END SUB
  452.  
  453.  
  454. '**
  455. '** Purpose:
  456. '**     Appends a file name to the end of a directory path,
  457. '**     inserting a backslash character as needed.
  458. '** Arguments:
  459. '**     szDir$  - full directory path (with optional ending "\")
  460. '**     szFile$ - filename to send to directory
  461. '** Returns:
  462. '**     Resulting fully qualified path name.
  463. '*************************************************************************
  464. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  465.     IF szDir$ = "" THEN
  466.         MakePath = szFile$
  467.     ELSEIF szFile$ = "" THEN
  468.         MakePath = szDir$
  469.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  470.         MakePath = szDir$ + szFile$
  471.     ELSE
  472.         MakePath = szDir$ + "\" + szFile$
  473.     END IF
  474. END FUNCTION
  475.  
  476.